package com.googlecode.gwt.test.plugin.util;

import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;

public class GwtCsvTestType {

  private static final String CLASS_NAME = "com.googlecode.gwt.test.csv.GwtCsvTest";

  public static IType getGwtCsvTestType(IProject project) {
    IJavaProject javaProject = JavaCore.create(project);
    IType type = null;
    try {
      type = javaProject.findType(CLASS_NAME);
    } catch (Exception e) {
      throw new RuntimeException("Error while finding class '" + CLASS_NAME
          + "' under eclipse project '" + javaProject.getProject().getName());
    }

    if (type == null) {
      throw new RuntimeException("Cannot find gwt-test-utils class '"
          + CLASS_NAME + "' in the classpath of project '" + project.getName()
          + "'");
    }

    return type;
  }
}
